package it.hopeless.jee6.welcome;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import java.io.Serializable;

/**
 * User: frico
 * Date: Jan 30, 2010
 * Time: 10:20:39 PM
 */
@ManagedBean(name = "welcome")
@ViewScoped
public class WelcomeController implements Serializable{
    private final static Logger logger = LoggerFactory.getLogger(WelcomeController.class);
    private String name;

    @EJB
    private WelcomeService welcome;

    public String getMessage() {
        logger.debug("Welcoming {}...",name);
        return welcome.getMessage()+", "+name+"!";
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void capitalize() {
        name = (name!=null)?name.toUpperCase():"";
    }
}
